import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bugly/flutter_bugly.dart';
import 'package:nyh_motorcade_app/utils/jverify_utils.dart';
import 'package:nyh_motorcade_app/utils/system_utils.dart';

class Config {
  static bool debug = env != Env.RELEASE;

  //http
  static const defaultMethod = "post";
  static const connectTimeout = 5000;
  static const receiveTimeout = 10000;
  static const systemType = "MOTORCADE_APPLICATION";

  //设置环境变量
  static Env env = Env.RELEASE;

  static String get baseUrl {
    switch (env) {
      case Env.DEV:
        return "http://192.168.1.254:8002/";
      case Env.DEBUG:
        return "https://customer.test.nengyuanh.cn/";
      case Env.PRE:
        return "https://customer.pre.nengyuanh.cn/";
      case Env.RELEASE:
        return "https://customer.nengyuanh.cn/";
      default:
        return "https://customer.nengyuanh.cn/";
    }
  }

  static void init(Env env) {
    Config.env = env;
    // Android透明状态栏,黑色字体
    if (Platform.isAndroid) {
      SystemUiOverlayStyle systemUiOverlayStyle = SystemUiOverlayStyle(
        systemNavigationBarColor: Colors.transparent,
        systemNavigationBarDividerColor: Colors.transparent,
        statusBarColor: Colors.transparent,
        systemNavigationBarIconBrightness: Brightness.dark,
        statusBarIconBrightness: Brightness.dark,
        statusBarBrightness: Brightness.dark,
      );
      SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
    }
    //初始化bug日志
    FlutterBugly.init(androidAppId: "99aebd5e94", iOSAppId: "6fb55db3a9");
    SystemUtils.getDeviceId().then((value) {
      FlutterBugly.setUserId(value);
    });
    //初始化极光
    JVerifyUtils.init();
  }

  static String getCooperateUrl() {
    switch (Config.env) {
      case Env.DEV:
        return "https://cooperation.nengyuanh.cn";
      case Env.DEBUG:
        return "https://cooperation.test.nengyuanh.cn";
      case Env.PRE:
        return "https://cooperation.pre.nengyuanh.cn";
      case Env.RELEASE:
        return "https://cooperation.nengyuanh.cn";
      default:
        return "https://cooperation.nengyuanh.cn";
    }
  }
}

enum Env {
  DEV,
  DEBUG,
  PRE,
  RELEASE,
}
